package ca.etsmtl.log730.projet2.connectors.clientserver.nodes;

import java.util.HashMap;

import org.apache.mina.core.session.IoSession;

public class SessionNodeMap extends HashMap<IoSession, NodeEntry> {
	private NodeEntry currentNode = new NodeEntry();
	
	@Override
	public NodeEntry put(IoSession key, NodeEntry value) {
		if(value.getUser() == null) {
			System.out.println("PEND CONNECTION " + value.toString());
		} else {
			System.out.println("NEW CONNECTION! " + value.toString());
		}
		return super.put(key, value);
	}

	@Override
	public NodeEntry remove(Object key) {
		if(key != null) {
			System.out.println("CONNECTION CLOSED! " + get(key).toString());
		}
		return super.remove(key);
	}

	public NodeEntry getCurrentNode() {
		return currentNode;
	}

	public void setCurrentNode(NodeEntry currentNode) {
		this.currentNode = currentNode;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -1111378861864527244L;

}
